Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling tag enumerator block if lookup returns nil tag #462

Merged
merged 2 commits into from
Jun 2, 2015

Conversation

dleehr
Copy link
Contributor

@dleehr dleehr commented Jun 2, 2015

Tag lookup may fail in GTRepositoryForeachTagCallback, resulting in a nil value for tag. This change skips the block if tag is nil.

Otherwise, a nil tag may be passed to the block. In the case of allTagsWithError:, the nil is added to an array, causing an exception or crash.

Otherwise, the tag enumerator block can be called with a nil GTTag, leading to an exception when allTagsWithError adds it to tagArray.
@joshaber joshaber self-assigned this Jun 2, 2015
@@ -457,7 +457,9 @@ static int GTRepositoryForeachTagCallback(const char *name, git_oid *oid, void *
GTTag *tag = (GTTag *)[info->myself lookUpObjectByGitOid:oid objectType:GTObjectTypeTag error:NULL];

BOOL stop = NO;
info->block(tag, &stop);
if (tag) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: do an explicit comparison != nil

@joshaber
Copy link
Member

joshaber commented Jun 2, 2015

Thanks! Just one note.

@dleehr
Copy link
Contributor Author

dleehr commented Jun 2, 2015

Fixed, thanks for the tip.

@joshaber
Copy link
Member

joshaber commented Jun 2, 2015

💥

joshaber added a commit that referenced this pull request Jun 2, 2015
Avoid calling tag enumerator block if lookup returns nil tag
@joshaber joshaber merged commit 5373acf into libgit2:master Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants